import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: () => import('../pages/Home.vue'),
    meta: {
      title: 'Home'
    }
  },
  {
    path: '/news',
    name: 'News',
    component: () => import('../pages/News.vue'),
    meta: {
      title: 'News'
    }
  },
  {
    path: '/news/detail',
    name: 'NewsDetail',
    component: () => import('../pages/NewsDetailWrapper.vue'),
    meta: {
      title: 'News Detail'
    }
  },
  {
    path: '/publications',
    name: 'Publications',
    component: () => import('../pages/Publications.vue'),
    meta: {
      title: 'Publications'
    }
  },
  {
    path: '/research',
    name: 'Research',
    component: () => import('../pages/Research.vue'),
    meta: {
      title: 'Research'
    }
  },
  {
    path: '/members',
    name: 'Members',
    component: () => import('../pages/Members.vue'),
    meta: {
      title: 'Members'
    }
  },
  {
    path: '/join-us',
    name: 'JoinUs',
    component: () => import('../pages/JoinUs.vue'),
    meta: {
      title: 'Join Us'
    }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { top: 0 }
    }
  }
})

export default router

